package com.example.a2306_shop.pay

import androidx.lifecycle.viewModelScope
import com.example.lib_base.entity.PayEntity
import com.example.lib_base.entity.Res
import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.param.Pay
import com.example.lib_base.utils.SingleLiveData
import kotlinx.coroutines.launch

class PayViewModel:BaseViewModel() {
    val paySuccess = SingleLiveData<Res<PayEntity>>()
    val payFail = SingleLiveData<String>()
    fun pay(pay: Pay){
        viewModelScope.launch {
            try {
                paySuccess.postValue(apiService.pay(pay))
            } catch (e: Exception) {
                payFail.postValue(e.message.toString())
            }
        }
    }
}